﻿using System;
using System.Windows;

namespace XamlTorrent.Utilities
{
    // TODO: Implement late binding of the dialog types.

    internal class DialogHelper
    {
        public static string OpenFile(FileDialogOptions options, Window owner)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            dlg.Title = options.Title;
            
            dlg.Filter = options.Filter;
            dlg.FilterIndex = options.FilterIndex;

            dlg.CheckFileExists = options.CheckFileExists;
            dlg.Multiselect = options.Multiselect;

            dlg.InitialDirectory = options.InitialDirectory;

            if (dlg.ShowDialog(owner) == true)
                return dlg.FileName;
            else
                return null;
        }

        public static string OpenDirectory(FileDialogOptions options, Window owner)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            dlg.Title = options.Title;
            dlg.Filter = "Folders|no.files";
            dlg.CheckFileExists = false;
            dlg.CheckPathExists = false;
            dlg.Multiselect = false;

            if (dlg.ShowDialog(owner) == true)
                return dlg.FileName;
            else
                return null;
        }

        public static string SaveFile(FileDialogOptions options, Window owner)
        {
            throw new NotImplementedException();
        }
    }
}
